#pragma once
#include <iostream>
using namespace std;


namespace bit
{
	class string
	{
	public:
		typedef char* iterator;
		typedef const char* const_iterator;
		string(const char* str = "")
		{
			_size = strlen(str);
			_capacity = _size;
			_str = new char[_capacity + 1];
			strcpy(_str, str);

		}
		~string()
		{
			_size = _capacity = 0;
			delete[] _str;
			_str = nullptr;
		}

		const char& operator[]( int pos)const
		{
			return _str[pos];
		}

		size_t size()
		{
			return _size;
		}
		const char* c_str()const
		{
			return _str;
		}
		void reserve(int n);
		void push_back(char ch);
		void append(const char* str);
		string& append(char ch);
		string& operator+=(const char* str);

		iterator begin()
		{
			return _str;
		}

		iterator end()
		{
			return _str + _size;
		}

		const_iterator begin()const
		{
			return _str;
		}

		const_iterator end()const
		{
			return _str + _size;
		}

		void insert(int pos,char ch);
		void insert(int pos,const char* str);

	private:
		char* _str;
		size_t _size;
		size_t _capacity;
	};

	void test1();

}